﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;

namespace Helper
{
    /// <summary>
    /// Helper class for Sql Server database.
    /// </summary>
    public class SqlServerDB : DbHelper
    {
        #region Constructor
        /// <summary>
        /// Constructor for default.
        /// </summary>
        public SqlServerDB()
            : base()
        {

        }

        /// <summary>
        /// use specific connection string to initialize Database helper.
        /// </summary>
        /// <param name="connectionString"></param>
        public SqlServerDB(string connectionString)
            : base(connectionString)
        {

        }

        /// <summary>
        /// Constructor for support the transaction.
        /// </summary>
        /// <param name="transaction">current transaction</param>		
        public SqlServerDB(DbTransaction transaction)
            : base(transaction)
        {

        }
        #endregion

        #region override
        /// <summary>
        /// initialize connection and command with specific connection string
        /// </summary>
        /// <param name="connectionString"></param>
        protected override void Initialize(string connectionString)
        {
            conn = new SqlConnection(connectionString);
            cmd = conn.CreateCommand();
        }

        /// <summary>
        /// Get DataAdapter for Sql Server
        /// </summary>
        /// <returns>DataAdapter for Sql Server</returns>
        protected override DbDataAdapter GetDataAdapter()
        {
            return new SqlDataAdapter();
        }
        #endregion


    }
}
